var uniquePathsWithObstacles = function(obstacleGrid) {
    if (obstacleGrid[0][0] === 1) {
        return 0
    }
    let cache = {}
    let m = obstacleGrid.length
    let n = obstacleGrid[0].length

    function gen(row, col) {
        if (row === 0 && col === 0) {
            return 1
        }
        if (row < 0 || row > m - 1 || col < 0 || col > n - 1) {
            return 0
        }
        if (obstacleGrid[row][col] === 1) {
            return 0
        }
        if (cache[row + '-' + col]) {
            return cache[row + '-' + col]
        } else {
            let temp = gen(row - 1, col) + gen(row, col - 1)
            cache[row + '-' + col] = temp
            return temp
        }
    }
    return gen(m - 1, n - 1)
};
console.log(uniquePathsWithObstacles([
    [1]
]))